import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/layout'

Vue.use(Router)

const routes = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index')
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    children: [
      {
        path: 'list',
        name: 'UserList',
        component: () => import('@/views/user/list')
      },
      {
        path: 'role',
        name: 'UserRole',
        component: () => import('@/views/user/role')
      }
    ]
  },
  {
    path: '/product',
    component: Layout,
    children: [
      {
        path: 'list',
        name: 'ProductList',
        component: () => import('@/views/product/list')
      },
      {
        path: 'category',
        name: 'ProductCategory',
        component: () => import('@/views/product/category')
      }
    ]
  },
  {
    path: '/order',
    component: Layout,
    children: [
      {
        path: 'list',
        name: 'OrderList',
        component: () => import('@/views/order/list')
      },
      {
        path: 'return',
        name: 'OrderReturn',
        component: () => import('@/views/order/return')
      }
    ]
  },
  {
    path: '/marketing',
    component: Layout,
    children: [
      {
        path: 'ad',
        name: 'MarketingAd',
        component: () => import('@/views/marketing/ad')
      },
      {
        path: 'position',
        name: 'MarketingPosition',
        component: () => import('@/views/marketing/position')
      }
    ]
  }
]

const router = new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router